package kafkastudy.rocketmq.simple;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

/**
 * Created by hp on 2019/9/25.
 */
public class SyncProducer {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer= new DefaultMQProducer("please_rename_unique_group_name");
        producer.setNamesrvAddr("10.1.1.152:9876");
        producer.start();
        for(int i=0;i<100;i++) {
            Message msg = new Message("TopicTest","TagA",
                    ("Hello RocketMQ " +
                            i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */);
            SendResult send = producer.send(msg);
            System.out.printf("%s%n",send);
        }

        producer.shutdown();
    }
}
